const sdk = require('weapps-plugin-citycode')

export default {
  onAppLaunch(launchOpts) {
    //初始化sdk信息
    sdk.init({
      appid: 'wx48526477b8b4b9a8', // 
      paasid: 'zgttest',
      tifhost: 'https://cpcpubdemo.pdcts.com.cn'
    })
    
    // 获取系统信息
    const systemInfo = wx.getSystemInfoSync();
    // 胶囊按钮位置信息
    const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
    // 导航栏高度 = 状态栏到胶囊的间距（胶囊距上距离-状态栏高度） * 2 + 胶囊高度 + 状态栏高度
    app.state.navBarHeight =
      (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 +
      menuButtonInfo.height +
      systemInfo.statusBarHeight;
    app.state.menuHeight = menuButtonInfo.height;
    if (!systemInfo.system.includes("iOS")) {
      // 非iOS系统下导航栏高度减去一定值以校正标题位置
      app.state.navBarHeight -= systemInfo.fontSizeSetting/3;
    }
    app.state.fontSizeSetting = systemInfo.fontSizeSetting;
    //console.log('---------> LifeCycle onAppLaunch', launchOpts)
  },
  onAppShow(appShowOpts) {
    //console.log('---------> LifeCycle onAppShow', appShowOpts)
  },
  onAppHide() {
    //console.log('---------> LifeCycle onAppHide')
  },
  onAppError(options) {
    //console.log('---------> LifeCycle onAppError', options)
  },
  onAppPageNotFound(options) {
    //console.log('---------> LifeCycle onAppPageNotFound', options)
  },
  onAppUnhandledRejection(options) {
    //console.log('---------> LifeCycle onAppUnhandledRejection', options)
  }
}